import axios from 'axios';
import uitl from '../common/js/util';
let base = 'auth';
let axios_config={responseType: 'json'};



/**
 * 同步登录用户信息
 * update by zlp 2017.12.25 创建方法
 * @params
 *
 * @return
 *      status
 *      msg
 *      datas
 *          user_info
 *          resources
 * **/
export const settingSync = params => {

    return  axios.post(`${base}/setting/info`, params);
}




/**--------用户列表--------**/

/**
 *  用户列表
 * Added by XWang 2018-06-26
 * */
export const userList = params => {
    return axios.post(`${base}/user_list`, params);
};
export const userNoPageList = params => {
    return axios.post(`${base}/no_page_user_list`, params);
};

export const userNoPageNoAdminList = params => {
    return axios.post(`${base}/no_page_user_list_no_admin`, params);
};


/**
 *  新增用户
 * Added by XWang 2018-06-26
 * */
export const addUser = params => {
    return axios.post(`${base}/user_add`, params);
};

/**
 *  更新用户
 * Added by XWang 2018-06-26
 * */
export const updateUser = params => {
    return axios.post(`${base}/user_update`, params);
};

/**
 *  删除用户
 * Added by XWang 2018-06-26
 * */
export const deleteUser = params => {
    return axios.post(`${base}/user_delete`, params);
};

/**
 *  用户详情
 * Added by XWang 2018-06-26
 * */
export const userInfo = params => {
    return axios.post(`${base}/user_info`, params);
};

/**
 *  用户列表
 * Added by XWang 2018-06-26
 * */
export const userRoleList = params => {
    return axios.post(`${base}/user_role_list`, params);
};

/**
 *  用户列表分页
 * Added by XWang 2018-06-26
 * */
export const userInfoOnPage = params => {
    return axios.post(`${base}/user_list_page`, params);
};

/**--------用户管理--------**/

/**
 *  当前用户（管理员）详情
 * Added by XWang 2018-06-26
 * */
// export const adminInfo = params => {
//     return axios.post(`${base}/admin`, params);
// };

/**
 *  用户详情
 * Added by XWang 2018-06-26
 * */
// export const resetUserPassword = params => {
//     return axios.post(`${base}/user_password`, params);
// };


/**
 *  所有实验室
 * Added by XWang 2018-06-25
 * */
// export const labAll = params => {
//     return axios.post(`${base}/lab_all`, params);
// };


/**
 *  用户实验室列表
 * Added by XWang 2018-06-25
 * */
// export const userLabList = params => {
//     return axios.post(`${base}/user_lab_list`, params);
// };

/**
 *  配置用户实验室
 * Added by XWang 2018-06-25
 * */
// export const addUserLab = params => {
//     return axios.post(`${base}/user_lab_add`, params);
// };

/**
 *  删除用户实验室
 * Added by XWang 2018-06-25
 * */
// export const deleteUserLab = params => {
//     return axios.post(`${base}/user_lab_delete`, params);
// };


/**
 *  所有院系
 * Added by XWang 2018-06-25
 * */
// export const unitAll = params => {
//     return axios.post(`${base}/unit_all`, params);
// };


/**
 *  用户院系列表
 * Added by XWang 2018-06-25
 * */
// export const userUnitList = params => {
//     return axios.post(`${base}/user_unit_list`, params);
// };

/**
 *  配置用户院系
 * Added by XWang 2018-06-25
 * */
// export const addUserUnit = params => {
//     return axios.post(`${base}/user_unit_add`, params);
// };

/**
 *  删除用户院系
 * Added by XWang 2018-06-25
 * */
// export const deleteUserUnit = params => {
//     return axios.post(`${base}/user_unit_delete`, params);
// };


/**--------在线用户--------**/

/**
 * 在线用户列表
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.page:第几页
 *
 * **/
export const getOnlineAdminUserList = params => {
    return  axios.post(`${base}/online_admin_user/listpage`, params);
}


/**
 * 强制退出
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.id:
 *
 * **/
export const exitAdminUser = params => {
    return  axios.post(`${base}/online_admin_user/exit`, params);
}





/**--------行为日志--------**/

/**
 * 行为日志列表
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.page:第几页
 *      params.type: 行为筛选
 *      params.start_date 开始时间
 *      params.end_date   结束时间
 *
 * **/
export const getSystemLogList = params => {
    return  axios.post(`${base}/system_log/listpage`, params);
}



/**--------个人设置--------**/
/**
 * 编辑系统参数
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.id:
 *      params.username:
 *      params.nickname:
 *      params.old_password:
 *      params.new_password:
 * **/
export const editCurrentUser = params => {
    return  axios.post(`${base}/setting/edit`, params);
}

export const editCurrentPassword = params => {
    return  axios.post(`${base}/setting/password`, params);
}




/**--------资源管理--------**/

/**
 * 资源列表
 * update by zlp 2017.12.19 创建方法
 * **/
export const getResourcesList = params => {
    return  axios.post(`${base}/resources/listpage`);
}

/**
 * 添加资源
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.lev:
 *      params.parent_id:
 *      params.name:
 *      params.uri:
 *      params.permission:
 *      params.type:
 *      params.code:
 *      params.status:
 *
 * **/
export const addResources = params => {
    return  axios.post(`${base}/resources/add`, params);
}

/**
 * 删除管理员用户
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.id:
 *
 * **/
export const removeResources = params => {
    return  axios.post(`${base}/resources/remove`, params);
}

/**
 * 编辑资源
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.id:
 *      params.name:
 *      params.uri:
 *      params.permission:
 *      params.type:
 *      params.code:
 *      params.status:
 *
 * **/
export const editResources = params => {
    return  axios.post(`${base}/resources/edit`, params);
}




/**--------角色管理--------**/

/**
 * 角色列表
 * update by zlp 2017.12.19 创建方法
 *   @params
 *      params.page:第几页
 *  @return
 *      total
 *      role_list[]
 * **/
export const getRoleList = params => {
    return  axios.post(`${base}/role_list`, params);
}

/**
 * 添加角色
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.role:
 *      params.description:
 *      params.status:
 *      params.resources: ID的数组
 * @return
 *      code        200
 *      message
 * **/
export const addRole = params => {
    return  axios.post(`${base}/role_add`, params);
}

/**
 * 删除角色
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.id:
 *
 * @return
 *      code        200
 *      message
 * **/
export const removeRole = params => {
    return  axios.post(`${base}/role_delete`, params);
}

/**
 * 编辑角色
 * update by zlp 2017.12.19 创建方法
 * @params
 *      params.id:
 *      params.role:
 *      params.description:
 *      params.status:
 *      params.resources: ID的数组
 *
 * @return
 *      code        200
 *      message
 * **/
export const editRole = params => {
    return  axios.post(`${base}/role_update`, params);
}

/* -----------文档管理-------------- */

/**
 *  文档列表
 *  Created by xwang 2018-06-28
 * */
// export const getDocumentList = params => {
//     return  axios.post(`${base}/document_list`, params);
// }

/**
 *  删除文档
 *  Created by xwang 2018-06-28
 * */
// export const deleteDocument = params => {
//     return  axios.post(`${base}/document_delete`, params);
// }


/**
 *  上传文档
 *  Created by xwang 2018-06-28
 * */
// export const addDocument = params => {
//     return  axios.post(`${base}/document_add`, params);
// }

/**
 *  文档详情
 *  Created by xwang 2018-06-28
 * */
// export const documentInfo = params => {
//     return  axios.post(`${base}/document_info`, params);
// }


/**
 *  文档消息详情
 *  Created by xwang 2018-06-28
 * */
// export const docMsgInfo = params => {
//     return  axios.post(`${base}/document_msg_info`, params);
// }


/**
 *  文档消息用户列表
 *  Created by xwang 2018-07-17
 * */
// export const docMsgUser = params => {
//     return axios.post(`${base}/document_msg_user`, params);
// };

/* -------------通知管理------------- */

/**
 *  通知列表
 *  Created by xwang 2018-06-28
 * */
// export const getMessageList = params => {
//     return  axios.post(`${base}/message_list`, params);
// }

/**
 *  新建通知
 *  Created by xwang 2018-06-28
 * */
// export const addMessage = params => {
//     return  axios.post(`${base}/message_add`, params);
// }

/**
 *  更改通知
 *  Created by xwang 2018-06-28
 * */
// export const updateMessage = params => {
//     return  axios.post(`${base}/message_update`, params);
// }

/**
 *  删除通知
 *  Created by xwang 2018-06-28
 * */
// export const deleteMessage = params => {
//     return  axios.post(`${base}/message_delete`, params);
// }

/**
 *  通知列表
 *  Created by xwang 2018-06-28
 * */
// export const messageInfo = params => {
//     return  axios.post(`${base}/message_info`, params);
// }


/* --------------自动审核--------------- */

/**
 *  审核详情
 *  Created by xwang 2018-06-28
 * */
// export const autoReviewList = params => {
//     return  axios.post(`${base}/auto_review_list`, params);
// }


/**
 *  更新审核
 *  Created by xwang 2018-06-28
 * */
// export const autoReviewUpdate = params => {
//     return  axios.post(`${base}/auto_review_update`, params);
// }





/**-------- 高校管理 --------**/

//高校列表 分页
export const universityList = params => {
    return axios.post(`${base}/university/listpage`, params);
};
//高校列表 不分页
export const universityNonPaged = params => {
    return axios.post(`${base}/university/non/listpage`, params);
};

//新增高校
export const addUniversity = params => {
    return axios.post(`${base}/university/add`, params);
};

//编辑高校
export const updateUniversity = params => {
    return axios.post(`${base}/university/update`, params);
};

//删除高校
export const removeUniversity = params => {
    return axios.post(`${base}/university/remove`, params);
};

//高校详情
export const universityInfo = params => {
    return axios.post(`${base}/university/info`, params);
};

//高校修改信息上传人
export const updateInfoManager = params => {
    return axios.post(`${base}/university/update_info_manager`, params);
};


//高校修改信息上传人
export const exportSafeCheckItemTemplate = params => {
    return axios.post(`${base}/university/export_safe_check_item_template`, params);
};


/**-------- 检查项管理 --------**/

//检查项列表
export const inspectItemList = params => {
    return axios.post(`${base}/inspect/listpage`, params);
};

//新增检查项 一级
export const addInspectItem = params => {
    return axios.post(`${base}/inspect/add`, params);
};

//新增检查项 二级
export const addInspectItemTwo = params => {
    return axios.post(`${base}/inspect/add_two`, params);
};

//新增检查项 三级
export const addInspectItemThree = params => {
    return axios.post(`${base}/inspect/add_three`, params);
};

//编辑检查项
export const updateInspectItem = params => {
    return axios.post(`${base}/inspect/update`, params);
};

//删除检查项
export const removeInspectItem = params => {
    return axios.post(`${base}/inspect/remove`, params);
};


/**-------- 检查结果设置 --------**/

//检查结果列表
export const checkResultList = params => {
    return axios.post(`${base}/check_result/listpage`, params);
};

//更新检查结果记录
export const editCheckResult = params => {
    return axios.post(`${base}/check_result/edit`, params);
};


export const getResourceUrl = params => {
    return  axios.post(`common/resource_url`, params);
};
